#include <iostream>
#include <stdio.h>
#include <cmath>

using namespace std;

int a[100];
int main() {
    int n,i = 0,j=0,n2=0,n3;
    cin >> n3;
    for(int k = 1; k <= n3; k ++){
        n = k;
        while(pow(10,i) <= n){
            i += 1;
        }
        for(int j = 1; j <= i; j ++){
            a[i-j] = n / int(pow(10,i-j)) % 10;
            n -= a[i-j]*pow(10,i-j);
        }
        for(int j = 0; j < i; j ++){
            if(a[j] == 1){
                n2 += 1;

            }
        }
    }
    cout << n2;
    return 0;
}